import React, { useState, createContext } from "react";
import Counter from "./Counter";

export const CountContext = createContext();

function Example4() {
  const [count, setCount] = useState(0); // 数组解构赋值

  return (
    <div>
      <p>You clicked {count} times</p>
      <button
        onClick={() => {
          setCount(count + 1);
        }}
      >
        Click me
      </button>
      <CountContext.Provider value={count}>
        <Counter></Counter>
      </CountContext.Provider>
    </div>
  );
}

export default Example4;
